<!DOCTYPE html>
<html lang="cn-zh">

<head>
  
  <meta charset="utf-8">



<meta name="viewport" content="width=device-width, initial-scale=1.0">


  <meta name="description" content="Android NDK 使用问题">


<meta name="color-scheme" content="light dark">







<meta name="generator" content="Hugo 0.111.2">

<meta content="Android, NDK, missing and no know rule, Qt, .so" name="keywords">
<meta content="Android NDK 引入外部动态库.so报错 missing and no known rule - 通通不同-博客" property="og:title">
<meta content="开发的乐趣在于相通而不同 - Android NDK 使用问题" property="og:description">

<meta name="msvalidate.01" content="F56ED94B7E86941E3DACEF208F07D329" />

  <title>
    
    Android NDK 引入外部动态库.so报错 missing and no known rule
     - 通通不同-博客
    
</title>

  <link rel="canonical" href="https://codebeautiful.gitee.io/post/android_ndk_missing_and_no_known_rule/">


  








  
    
  
  
  <link rel="stylesheet" href="/css/base.min.4f231885947d13c748c815d93da49f07ab89afb67629f9970b7c054610e88e0b.css" integrity="sha256-TyMYhZR9E8dIyBXZPaSfB6uJr7Z2KfmXC3wFRhDojgs=" crossorigin="anonymous">



</head>

<body>
  <nav class="u-background">
  <div class="u-wrapper">
    <ul class="Banner">
      <li class="Banner-item Banner-item--title">
        <h1 class="Banner-heading">
          <a class="Banner-link u-clickable" href="/">通通不同-博客</a>
        </h1>
      </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/post/">全部</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/categories/">分类</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/tags/">标签</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/about/">关于</a>
        </li>
      
    </ul>
  </div>
</nav>

  <main>
    <div class="u-wrapper">
      <div class="u-padding">
        

  <article>
    <header class="Heading">
  <h2 class="Heading-title">
    <a class="Heading-link u-clickable" href="/post/android_ndk_missing_and_no_known_rule/" rel="bookmark">Android NDK 引入外部动态库.so报错 missing and no known rule</a>
  </h2>
  
    <time datetime="2023-04-01T07:08:32&#43;08:00">1 April, 2023</time>
  
</header>

    <h3 id="正确的配置项-cmake">
  <a class="Heading-link u-clickable" href="/post/android_ndk_missing_and_no_known_rule/#%e6%ad%a3%e7%a1%ae%e7%9a%84%e9%85%8d%e7%bd%ae%e9%a1%b9-cmake">正确的配置项-cmake</a>
</h3>

<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-cmake" data-lang="cmake"><span style="display:flex;"><span>add_library( <span style="color:#e6db74">qtcore</span>
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">SHARED</span>
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">IMPORTED</span> )<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>set_target_properties( <span style="color:#75715e"># Specifies the target library.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>              <span style="color:#e6db74">qtcore</span>
</span></span><span style="display:flex;"><span>              <span style="color:#75715e"># Specifies the parameter you want to define.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>              <span style="color:#e6db74">PROPERTIES</span> <span style="color:#e6db74">IMPORTED_LOCATION</span>
</span></span><span style="display:flex;"><span>              <span style="color:#75715e"># 关键点在这里，这个路径必须为绝对路径，报错原因是因为使用了相对路径
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>              <span style="color:#f92672">${</span>PROJECT_SOURCE_DIR<span style="color:#f92672">}</span><span style="color:#e6db74">/../libs/</span><span style="color:#f92672">${</span>ANDROID_ABI<span style="color:#f92672">}</span><span style="color:#e6db74">/libQt6Core.so</span> )<span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010"></span>target_link_libraries( <span style="color:#75715e"># Specifies the target library.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>              <span style="color:#e6db74">shared</span>
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">qtcore</span>
</span></span><span style="display:flex;"><span>              <span style="color:#75715e"># Links the target library to the log library
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>              <span style="color:#75715e"># included in the NDK.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>              <span style="color:#f92672">${</span>log-lib<span style="color:#f92672">}</span>)</span></span></code></pre></div>
<ul>
<li>关键点在这里，这个路径必须为绝对路径，报错原因是因为使用了相对路径</li>
</ul>

    


  

  

  





  <footer>
    
      
    
      
    
      
        <ul class="Tags">
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/android/" rel="tag">Android</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/ndk/" rel="tag">NDK</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/qt/" rel="tag">Qt</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/cmake/" rel="tag">cmake</a>
            </li>
          
        </ul>
      
    
  </footer>

    
  

  </article>


      </div>
    </div>
  </main>
  
  <footer class="Footer">
    <div class="u-wrapper">
      <div class="u-padding">
        开发的乐趣在于相通而不同
      </div>
    </div>
  </footer>


  <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?d08a2ad355cb7a065a41be081b43297e";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>

</html>
